<% truncate_length_for_boxes = 22 -%>
	<ul class="buttons">
<% if logged_in? -%>
	  <li><%= icon "new", new_survey_url, "Create a new survey", nil, "Create a new survey" %></li>
	<% if controller.action_name == "show" %>
		<% if current_user.is_admin? && @survey.survey_type.is_ukda %>
	<li><%= icon "new", url_for({:action => "new", :controller=> "datasets",:survey => @survey.id}), "Add a dataset to this survey", nil, "Add a dataset to this survey" -%></li>
	<% elsif Authorization.is_authorized?("edit", nil, @survey, current_user) %>
		<li><%= icon "new", url_for({:action => "new", :controller=> "datasets",:survey => @survey.id}), "Add a dataset to this survey", nil, "Add a dataset to this survey" -%></li>
		<li><%= icon "edit", edit_survey_url(@survey), "Edit this survey", nil, "Edit this survey" -%></li>
	<% end %>
	<% end %>
		<% end -%>
	</ul>
<h1 class="contribution_title">Survey: <%= h(@survey.title) -%></h1>
<div class="left" style="width: 20%;">
	<% unless @all_categories.empty? -%>
	<%= render :partial => "categories_list" -%>
	<% else %>
	There are no categories listed for this survey
	<% end %>
</div>
<div class="show_basic right" style="width:70%;">
    	<div class="box_about_actor">
      		<p>
        		<b>Title:</b>
        		<span class="title"><%=h @survey.title -%></span>
      		</p>
      		<p>
        		<b>Type:</b>
        		<%=h @survey.survey_type.shortname -%>
      		</p>
      		<p>
        		<b>Description</b>
        		<% unless @survey.description.blank? -%>
        			<div class="box_standout">
          				<%= simple_format(white_list(@survey.description)) -%>
        			</div>
      			<% else -%>
        			<p class="none_text">
          				No description
        			</p>
      			<% end -%>
      		</p>
      		<p>
        		<b>Child Datasets:</b>
        		<% if !@survey.datasets.empty? -%>
					<% @survey.datasets.each do |dataset| -%>
            			<%= link_to(h(dataset.name), dataset_path(dataset)) -%>
          			<% end -%>
        		<% else -%>
          		None
        		<% end -%>
      		</p>
      		<br/>
			<% if logged_in? %>
				<div class="link_box">
					Show: 
					<%= link_to_remote "Only my links", :url=> show_links_surveys_path, :with=> "'link_state=mine&survey_id=#{@survey.id}'" %>, 
					<%= link_to_remote "All links", :url=> show_links_surveys_path, :with=> "'link_state=all&survey_id=#{@survey.id}'" %>
				</div>
			<% end -%>
			<div class="actual_link_box">
				<div id="links">
      				<b>Linked with Data Extracts(s):</b>
      				<% if !@archives.empty? -%>
        				<% @archives.each do |archive| -%>
          					<%= link_to(archive.title, csvarchive_path(archive)) -%>
        				<% end -%>
      				<% else -%>
        			None
      				<% end -%>
      				<br/>
					<br/>
      				<b>Linked with Script(s):</b>
					<% if !@scripts.empty? -%>
        				<% @scripts.each do |script| -%>
          					<%= link_to(script.title, script_path(script)) -%>
        				<% end -%>
      				<% else -%>
        			None
      				<% end -%>
				</div>
			</div>
      		<br/>
      		<br/>
      		<br/>
			<% if @survey.UKDA_summary || @survey.headline_report -%>
      			<p>
        			<b>Further information</b>
      				<div class="box_standout">        
						<% if @survey.UKDA_summary -%>
        					<a href="<%= @survey.UKDA_summary%>">ESDS Summary</a><br/>
						<% end -%>
        				<% if @survey.headline_report -%>
          					<a href="<%= @survey.headline_report%>">Headline Report</a>
        				<% end -%>
  	      			</div>
				</p>
			<% end -%>
			<br/>
			<% if logged_in? -%>
				<% if @forum != nil -%>
					<b>Forum</b>
					<div class="box_standout">
						<%= link_to h("View the forum"), forum_path(@forum), :class => "title" %>
    				</div>
				<% end -%>
				<% if @forum != nil -%>
      				<% if @forum.recent_post -%>
						<div class="box_standout">
							<b>Recent forum activity</b>
							<br/>
							<br/>
        					<%= time_ago_in_words(@forum.recent_post.created_at) -%><br />
        					<%= '{user}'[:by_user,"<strong>#{h(@forum.recent_post.user.display_name)}</strong>"] -%>
		replied <strong><%= @forum.recent_post.body -%></strong>
		to <strong><%= @forum.recent_post.topic.title -%></strong>
        <span>(<%= link_to 'view'[], forum_topic_path(:forum_id => @forum, :id => @forum.recent_post.topic_id, :page => @forum.recent_post.topic.last_page, :anchor => @forum.recent_post.dom_id) -%>)</span>
						</div>
      				<% end -%>
				<% end -%>
			<% end -%>
    	</div>
		<div class="left">
			<% if current_user %>
			<h3>Notes</h3>
			  <%= render :partial => "notes/add_note", :locals=>{:resource_id => @survey.id} -%>
					<% @notes.each do |note| %>
					<%= render :partial => "notes/note", :locals=>{:note=>note} %>
					<% end %>
					<div id="new_note">
						</div>
						<% end %>
		</div>
		<% if current_user %>
		<div class="resource-comments right">
		<h3>Comments</h3>
		  <%= render :partial => "comments/add_comment", :locals=>{:resource_id => @survey.id} -%>
				<% @comments.each do |comment| %>
				<%= render :partial => "comments/comment", :locals=>{:comment=>comment} %>
				<% end %>
				<div id="new_comment">
					</div>
		</div>
		<% end %>
</div>
<div style="clear:both;">
</div>